Skip to content

Enable tracing for RabbitMQ Component (v7)#15659

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/enable-tracing-rabbitmq-component
Draft

Enable tracing for RabbitMQ Component (v7)#15659
Copilot wants to merge 2 commits intomainfrom
copilot/enable-tracing-rabbitmq-component

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 27, 2026

RabbitMQ.Client v7 ships built-in OpenTelemetry activity sources (RabbitMQ.Client.Publisher and RabbitMQ.Client.Subscriber). The code to register these sources via AddSource("RabbitMQ.Client.*") was already in place for v7 but lacked conformance tests and documentation.

Changes

ConformanceTests.cs

  • Set ActivitySourceName conditionally: "Aspire.RabbitMQ.Client" for v6, "RabbitMQ.Client.Publisher" for v7
  • Added TracingEnablesTheRightActivitySource / TracingEnablesTheRightActivitySource_Keyed tests (v7 only via #if !RABBITMQ_V6), following the same pattern as Npgsql/MySqlConnector
  • Custom RunActivitySourceTest instead of base class ActivitySourceTest: IConnection creation generates connection activities before TriggerActivity is called, which breaks the base class Assert.Empty check — the custom method clears those before asserting on publisher activities
  • Refactored PopulateConfiguration to use a stored ConnectionString property (required to pass the connection string into the RemoteExecutor subprocess)

README.md

  • Added Observability section documenting the three activity sources (Aspire.RabbitMQ.Client, RabbitMQ.Client.Publisher, RabbitMQ.Client.Subscriber)
  • Fixed Usage example: _AppHost.cs__Program.cs_

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
    • No
  • Does the change require an update in our Aspire docs?
    • Yes
    • No

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…ment activity sources

Agent-Logs-Url: https://github.com/microsoft/aspire/sessions/e76fd16a-3b81-420a-88f1-bc598cf74a4d

Co-authored-by: maddymontaquila <12660687+maddymontaquila@users.noreply.github.com>
Copilot AI changed the title [WIP] Enable tracing for RabbitMQ component with v7 Enable tracing for RabbitMQ Component (v7) Mar 27, 2026
Copilot AI requested a review from maddymontaquila March 27, 2026 23:49
@maddymontaquila
Copy link
Copy Markdown
Contributor

@eerhardt i thought this might be an easy one but feels like slop lol. are we up to date w rabbitmq and does it have tracing now?


protected override string ActivitySourceName => "";
#if RABBITMQ_V6
protected override string ActivitySourceName => "Aspire.RabbitMQ.Client";
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this get used for v6?

builder.AddRabbitMQClient("messaging", configureConnectionFactory: factory => factory.ClientProvidedName = "MyApp");
```

## Observability
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have this section in other READMEs? I don't see it.

Copy link
Copy Markdown
Member

@eerhardt eerhardt Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We track these in https://github.com/microsoft/aspire/blob/main/src/Components/Telemetry.md - which doesn't have the new ones - RabbitMQ.Client.Publisher and Subscriber

RunWithConnectionString(connectionStringToUse, static obj => obj.RunActivitySourceTest(key: "key")),
ConnectionString, Output);

private void RunActivitySourceTest(string? key)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't this call the base test method?

// This method can have side effects (setting AppContext switch, enabling activity source by name).
// That is why it needs to be executed in a standalone process.
// We use RemoteExecutor for that, but it does not support abstract classes
// (it can not determine the type to instantiate), so that is why this "test"
// is here and derived types call it
protected void ActivitySourceTest(string? key)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable Tracing for RabbitMQ Component when we move to their v7

3 participants